<template>
  <div class="home-content">
    <section class="hero-section">
      <div class="hero-content">
        <h1 class="hero-title">探索3D世界的无限可能</h1>
        <p class="hero-subtitle">上传、压缩、编辑、分享您的3D模型</p>
        <button class="experience-btn" @click="handleUploadClick">立即体验</button>
      </div>
      <div class="hero-visual">
        <div class="floating-cube">
          <div class="cube-face front"></div>
          <div class="cube-face back"></div>
          <div class="cube-face right"></div>
          <div class="cube-face left"></div>
          <div class="cube-face top"></div>
          <div class="cube-face bottom"></div>
        </div>
      </div>
    </section>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'

const router = useRouter()

// 处理上传点击 - 在新窗口打开编辑器
const handleUploadClick = () => {
  // 打开新窗口跳转到编辑器
  const editorUrl = router.resolve({ path: '/editor' }).href
  window.open(editorUrl, '_blank')
  
  // 触发父组件的上传功能（如果需要）
  const event = new CustomEvent('upload-click')
  window.dispatchEvent(event)
}
</script>

<style scoped>
.home-content {
  min-height: calc(80vh - 50px);
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.hero-section {
  display: flex;
  align-items: center;
  min-height: 60vh;
  padding: 80px 20px;
  background: white;
  color: #333;
  position: relative;
  overflow: hidden;
}

.hero-content {
  flex: 1;
  max-width: 600px;
  z-index: 2;
  margin-left: 350px;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  line-height: 1.3;
  color: #333;
}

.hero-subtitle {
  font-size: 1.1rem;
  margin-bottom: 2rem;
  color: #666;
  line-height: 1.6;
}

.experience-btn {
  background: white;
  color: #3742fa;
  border: 2px solid #3742fa;
  padding: 12px 32px;
  border-radius: 25px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.experience-btn:hover {
  background: #3742fa;
  color: white;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

.hero-visual {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

/* 3D立方体动画 */
.floating-cube {
  width: 120px;
  height: 120px;
  position: relative;
  transform-style: preserve-3d;
  animation: float 12s ease-in-out infinite;
}

.cube-face {
  position: absolute;
  width: 120px;
  height: 120px;
  background: rgba(55, 66, 250, 0.1);
  border: 2px solid rgba(55, 66, 250, 0.3);
  backdrop-filter: blur(10px);
}

.cube-face.front { transform: rotateY(0deg) translateZ(60px); }
.cube-face.back { transform: rotateY(180deg) translateZ(60px); }
.cube-face.right { transform: rotateY(90deg) translateZ(60px); }
.cube-face.left { transform: rotateY(-90deg) translateZ(60px); }
.cube-face.top { transform: rotateX(90deg) translateZ(60px); }
.cube-face.bottom { transform: rotateX(-90deg) translateZ(60px); }

@keyframes float {
  0% { transform: rotateX(0deg) rotateY(0deg) rotateZ(0deg); }
  12.5% { transform: rotateX(45deg) rotateY(45deg) rotateZ(0deg); }
  25% { transform: rotateX(90deg) rotateY(90deg) rotateZ(0deg); }
  37.5% { transform: rotateX(90deg) rotateY(135deg) rotateZ(45deg); }
  50% { transform: rotateX(90deg) rotateY(180deg) rotateZ(90deg); }
  62.5% { transform: rotateX(135deg) rotateY(180deg) rotateZ(135deg); }
  75% { transform: rotateX(180deg) rotateY(180deg) rotateZ(180deg); }
  87.5% { transform: rotateX(225deg) rotateY(225deg) rotateZ(180deg); }
  100% { transform: rotateX(270deg) rotateY(270deg) rotateZ(180deg); }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .hero-title {
    font-size: 2rem;
  }
  
  .hero-subtitle {
    font-size: 1rem;
  }
  
  .experience-btn {
    padding: 10px 24px;
    font-size: 0.9rem;
  }
  
  .hero-content {
    margin-left: 20px;
  }
  
  .floating-cube {
    width: 80px;
    height: 80px;
  }
  
  .cube-face {
    width: 80px;
    height: 80px;
  }
  
  .cube-face.front { transform: rotateY(0deg) translateZ(40px); }
  .cube-face.back { transform: rotateY(180deg) translateZ(40px); }
  .cube-face.right { transform: rotateY(90deg) translateZ(40px); }
  .cube-face.left { transform: rotateY(-90deg) translateZ(40px); }
  .cube-face.top { transform: rotateX(90deg) translateZ(40px); }
  .cube-face.bottom { transform: rotateX(-90deg) translateZ(40px); }
}
</style>
